SELECT 'USE [Master]; ' +
'ALTER DATABASE ' + QUOTENAME(name) + ' SET RECOVERY SIMPLE WITH NO_WAIT; ' +
'USE ' + QUOTENAME(name) + '; ' +
'DBCC SHRINKFILE(' + REPLACE(REPLACE(QUOTENAME(name), ']',''),'[','') + '_Log, 1)' +
'USE [Master]; ' +
'ALTER DATABASE ' +QUOTENAME(name) +' SET RECOVERY FULL WITH NO_WAIT; '
AS [To Execute]
FROM sys.databases
'ALTER DATABASE ' + QUOTENAME(name) + ' SET RECOVERY SIMPLE WITH NO_WAIT; ' +
'USE ' + QUOTENAME(name) + '; ' +
'DBCC SHRINKFILE(' + REPLACE(REPLACE(QUOTENAME(name), ']',''),'[','') + '_Log, 1)' +
'USE [Master]; ' +
'ALTER DATABASE ' +QUOTENAME(name) +' SET RECOVERY FULL WITH NO_WAIT; '
AS [To Execute]
FROM sys.databases